package com.app.core.security;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.convert.Convert;

/**
 * @author qiangt
 * @version 1.0
 * @date 2024/3/28 11:55
 * @description: 自定义token生成策略
 */
public class TokenStrategy {
    public static String generateToken(String userId) {
        String plainText = Convert.toStr(userId).concat("@").concat(Convert.toStr(System.currentTimeMillis()));
        return Base64.encode(plainText);
    }

    public static String tokenToUserId(String token) {
        return Base64.decodeStr(token).split("@")[0];
    }
}
